<template>
  <div class="query" :style="style">
    <span class="logo">
      <el-tooltip class="item" effect="dark" content="菜单" placement="bottom">
        <i class="iconfont icon-hanbao" @click="contentVisible = !contentVisible"></i>
      </el-tooltip>
    </span>
    <div class="title">基层查询分析</div>
    <div class="content" v-show="contentVisible">
      <!-- 样板 -->
      <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
    </div>
  </div>
</template>

<script>
import * as Data from '../index.js'
export default {
  name: 'Query',
  data () {
    return {
      treeData: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      contentVisible: false,
      style: {}
    }
  },
  created () {
    this.initData()
  },
  methods: {
    initData () {
      this.treeData = Data.queryList.slice(0)
    },
    handleNodeClick (data) {
      console.log(data)
    }
  },
  watch: {
    contentVisible () {
      if (!this.contentVisible) {
        this.style = {
          height: '60px'
        }
      } else {
        this.style = {
          height: 'calc(100% - 50px)'
        }
      }
      this.$emit('querystyle', this.style)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "../../../assets/css/rule.scss";
.query {
  width: 350px;
  height: 100%;
  box-sizing: border-box;
  .logo {
    float: right;
    height: 60px;
    line-height: 60px;
    width: 50px;
    background-color: $backGroundColor;
  }
  .title {
    font-size: $fontSizeNav;
    color: $fontColor;
    font-weight: bold;
    text-align: center;
    height: 60px;
    line-height: 60px;
    background-color: $backGroundColor;
    box-shadow: 2px 5px 5px rgba(0, 0, 0, 0.3);
  }
  .content {
    height: calc(100% - 70px);
    overflow: auto;
    background-color: $backGroundColor;
    box-shadow: 2px 5px 5px rgba(0, 0, 0, 0.3);
  }
}
</style>
<style rel="stylesheet/scss" lang="scss">
@import "../../../assets/css/rule.scss";
// .query {
.el-tree {
  color: $fontColor;
  background-color: $backGroundColor;
}
.el-tree-node__content:hover {
  background-color: $backGroundColor;
}
</style>
